package com.fcmeditech.AsianSexyGirls.File;

import java.io.File;
import android.content.Context;

public class FavorisCache {
    
    private File cacheFavoris;
    
    public FavorisCache(Context context){
        //Find the dir to save cached images
        if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED))
            cacheFavoris=new File(android.os.Environment.getExternalStorageDirectory(),"FavorisImage");
        else
            cacheFavoris=context.getCacheDir();
        if(!cacheFavoris.exists())
            cacheFavoris.mkdirs();
    }
    
    public File getFile(String url){
        //I identify images by hashcode. Not a perfect solution, good for the demo.
        String filename=String.valueOf(url.hashCode());
        File f = new File(cacheFavoris, filename);
        return f;
        
    }
    
//    
//    public void all(){
//    	File[] files=cacheFavoris.listFiles();
//    	
//    	for(File f:files)
//    		
//    }
    public void clear(){
        File[] files=cacheFavoris.listFiles();
        
        for(File f:files)
            f.delete();
    }

}